package com.bruce.starts.demo.utils;

import net.sourceforge.pinyin4j.PinyinHelper;

public class PyUtils {
    public static String getPYName(String str) {
        String PYName = "";
        for (int i = 0; i < str.length(); i++) {
            char word = str.charAt(i);
            String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
            if (pinyinArray != null) {
                PYName += pinyinArray[0].replaceAll("[0-9]","");
            } else {
                PYName += word;
            }
        }
        return PYName;
    }
}
